package waitandnotify02;

import java.util.concurrent.ArrayBlockingQueue;

public class Consumer extends Thread{
    private ArrayBlockingQueue<String> queue;

    public Consumer(String name,ArrayBlockingQueue<String> queue){
        super(name);
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true){
            // 1.不断的从阻塞队列中获取面条
            String food = null;
            try {
                // take方法的底层也是有Lock锁的
                food = queue.take();
                System.out.println(food);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
